package 简单.拆炸弹;

import java.util.Arrays;

/**
 * @author liugongding
 * @description:
 * @date 2024/9/4 9:54 PM
 */
public class Solution {

    public static int[] decrypt(int[] code, int k) {
        if (k == 0) {
            //Arrays
        }
        int[] newArray = new int[code.length];
        for (int i = 0; i < code.length; i++) {
            if (k > 0) {
                newArray[i] = get(i+1, code) + get(i+2, code) + get(i+3, code);
            } else if (k < 0) {
                newArray[i] = get(i+1, code) + get(i+2, code) + get(i+3, code);
            }
        }
        return newArray;
    }



    public static void main(String[] args) {
        int[] a = {5,7,1,4};
        String string = Arrays.toString(decrypt(a, 3));
        System.out.println(string);

        int[] newArray = {};
        int i = get(4, a);
        System.out.println(i);
    }

    public static int get(int index, int[] array) {
        index = index % array.length;  // 确保索引是循环的
        if (index < 0) {
            index += array.length;  // 处理负索引情况
        }
        return array[index];
    }
}
